home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / 92052tar.gz / 920528.tar / iface.h < prev    next >
C/C++ Source or Header  |  1992-05-28  |  5KB  |  151 lines

  1. /* @(#) $Header: iface.h,v 1.12 92/05/28 13:50:16 deyke Exp $ */
  2.  
  3. #ifndef _IFACE_H
  4. #define _IFACE_H
  5.  
  6. #ifndef _GLOBAL_H
  7. #include "global.h"
  8. #endif
  9.  
  10. #ifndef _MBUF_H
  11. #include "mbuf.h"
  12. #endif
  13.  
  14. #ifndef _PROC_H
  15. #include "proc.h"
  16. #endif
  17.  
  18. #include <stdio.h>
  19.  
  20. /* Interface encapsulation mode table entry. An array of these structures
  21.  * are initialized in config.c with all of the information necessary
  22.  * to attach a device.
  23.  */
  24. struct iftype {
  25.     char *name;             /* Name of encapsulation technique */
  26.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  27.                 /* Routine to send an IP datagram */
  28.     int (*output) __ARGS((struct iface *,char *,char *,int,struct mbuf *));
  29.                 /* Routine to send link packet */
  30.     char *(*format) __ARGS((char *,char *));
  31.                 /* Function that formats addresses */
  32.     int (*scan) __ARGS((char *,char *));
  33.                 /* Reverse of format */
  34.     int type;               /* Type field for network process */
  35.     int hwalen;             /* Length of hardware address, if any */
  36. };
  37. #define NULLIFT (struct iftype *)0
  38. extern struct iftype Iftypes[];
  39.  
  40. /* Interface control structure */
  41. struct iface {
  42.     struct iface *next;     /* Linked list pointer */
  43.     char *name;             /* Ascii string with interface name */
  44.  
  45.     int32 addr;             /* IP address */
  46.     int32 broadcast;        /* Broadcast address */
  47.     int32 netmask;          /* Network mask */
  48.  
  49.     int16 mtu;              /* Maximum transmission unit size */
  50.  
  51.     int16 flags;            /* Configuration flags */
  52. #define DATAGRAM_MODE   0       /* Send datagrams in raw link frames */
  53. #define CONNECT_MODE    1       /* Send datagrams in connected mode */
  54.  
  55.     int16 trace;            /* Trace flags */
  56. #define IF_TRACE_OUT    0x01    /* Output packets */
  57. #define IF_TRACE_IN     0x10    /* Packets to me except broadcast */
  58. #define IF_TRACE_ASCII  0x100   /* Dump packets in ascii */
  59. #define IF_TRACE_HEX    0x200   /* Dump packets in hex/ascii */
  60. #define IF_TRACE_NOBC   0x1000  /* Suppress broadcasts */
  61. #define IF_TRACE_RAW    0x2000  /* Raw dump, if supported */
  62.     char *trfile;           /* Trace file name, if any */
  63.     FILE *trfp;             /* Stream to trace to */
  64.  
  65.     struct iface *forw;     /* Forwarding interface for output, if rx only */
  66.  
  67.     void (*rxproc) __ARGS((struct iface *)); /* Receiver process, if any */
  68.     struct proc *txproc;    /* IP send process */
  69.     struct proc *supv;      /* Supervisory process, if any */
  70.  
  71.     /* Device dependent */
  72.     int dev;                /* Subdevice number to pass to send */
  73.                 /* To device -- control */
  74.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  75.                 /* From device -- when status changes */
  76.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  77.                 /* Call before detaching */
  78.     int (*stop) __ARGS((struct iface *));
  79.     char *hwaddr;           /* Device hardware address, if any */
  80.  
  81.     /* Encapsulation dependent */
  82.     void *edv;              /* Pointer to protocol extension block, if any */
  83.     int type;               /* Link header type for phdr */
  84.     int xdev;               /* Associated Slip or Nrs channel, if any */
  85.     struct iftype *iftype;  /* Pointer to appropriate iftype entry */
  86.  
  87.                 /* Routine to send an IP datagram */
  88.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  89.             /* Encapsulate any link packet */
  90.     int (*output) __ARGS((struct iface *,char *,char *,int,struct mbuf *));
  91.             /* Send raw packet */
  92.     int (*raw)              __ARGS((struct iface *,struct mbuf *));
  93.             /* Display status */
  94.     void (*show)            __ARGS((struct iface *));
  95.  
  96.     int (*discard)          __ARGS((struct iface *,struct mbuf *));
  97.     int (*echo)             __ARGS((struct iface *,struct mbuf *));
  98.  
  99.     /* Counters */
  100.     int32 ipsndcnt;         /* IP datagrams sent */
  101.     int32 rawsndcnt;        /* Raw packets sent */
  102.     int32 iprecvcnt;        /* IP datagrams received */
  103.     int32 rawrecvcnt;       /* Raw packets received */
  104.     int32 lastsent;         /* Clock time of last send */
  105.     int32 lastrecv;         /* Clock time of last receive */
  106.  
  107.     int sendcrc;            /* Send CRC if true (KISS only) */
  108.     int32 crcerrors;        /* Packets received with CRC errors (KISS only) */
  109.     int32 ax25errors;       /* Packets received with bad ax25 header */
  110. };
  111. #define NULLIF  (struct iface *)0
  112. extern struct iface *Ifaces;    /* Head of interface list */
  113. extern struct iface  Loopback;  /* Optional loopback interface */
  114. extern struct iface  Encap;     /* IP-in-IP pseudo interface */
  115.  
  116. /* Header put on front of each packet sent to an interface */
  117. struct qhdr {
  118.     char tos;
  119.     int32 gateway;
  120. };
  121. /* List of link-level receive functions, initialized in config.c */
  122. struct rfunc {
  123.     int class;
  124.     void (*rcvf) __ARGS((struct iface *,struct mbuf *));
  125. };
  126. extern struct rfunc Rfunc[];
  127.  
  128. /* Header put on front of each packet in input queue */
  129. struct phdr {
  130.     struct iface *iface;
  131.     unsigned short type;    /* Use pktdrvr "class" values */
  132. };
  133.  
  134. extern char Noipaddr[];
  135. extern struct mbuf *Hopper;
  136.  
  137. /* In iface.c: */
  138. struct iface *if_lookup __ARGS((char *name));
  139. struct iface *ismyaddr __ARGS((int32 addr));
  140. int if_detach __ARGS((struct iface *ifp));
  141. int setencap __ARGS((struct iface *ifp,char *mode));
  142. char *if_name __ARGS((struct iface *ifp,char *comment));
  143. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  144. void if_tx __ARGS((int dev,void *arg1,void *unused));
  145. void network __ARGS((int i,void *v1,void *v2));
  146.  
  147. /* In config.c: */
  148. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  149.  
  150. #endif  /* _IFACE_H */
  151.